﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QLKetNoi;
using System.Data.Linq;

namespace QLPhanQuyen.DAO
{
    public class ChucNangConDAO
    {
        QLDNDataContext db = new QLDNDataContext();
        Table<CHUCNANGCON> chucNangCons;

        public List<string> DSChucNangConTheoChucNang(string maChucNang)
        {
            chucNangCons = db.GetTable<CHUCNANGCON>();

            var query = (from cncs in chucNangCons
                         where cncs.MaChucNang == maChucNang
                         select cncs.TenChucNangCon).ToList();
            return query;
        }

        public string LayMaTheoTen(string ten)
        {
            chucNangCons = db.GetTable<CHUCNANGCON>();

            var query = (from cnc in chucNangCons
                         where cnc.TenChucNangCon == ten
                         select cnc.MaChucNangCon).FirstOrDefault();
            return query;
        }
    }
}
